<?php defined('IN_IA') or exit('Access Denied');?><!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>个人中心</title>
    <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/mobile/theme/public.min.css">
    <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/mobile/css/personal.css">
</head>

<body>
    <!-- 顶部 -->
    <div class="head">
        <div class="user">
            <img class="user_pic" src="<?php  echo tomedia($user['avatar']);?>" alt="">
            <p><?php  echo $user['nickname'];?></p>
            <!-- <p><?php  echo $personaldata['openid'];?></p> -->
        </div>
        <!-- <audio id="Jaudio" class="media-audio" src=""  loop="true" ></audio>
        <div class="music_control btn-ani">
            <img class="play_btn" src="<?php echo WEB_RESOURCE;?>/mobile/images/icon/music.png" alt="">
        </div> -->
    </div>
    <!-- 顶部 -->
    <!-- 红包返利记录 -->
    <div class="package">
        <div class="package_con">
            <p class="package_title">红包返利记录</p>
            <div class="package_table">
                <table class="package_list">
                    <tr>
                        <th>金额</th>
                        <th>时间</th>
                        <th>类型</th>
                        <th>被推荐人</th>
                    </tr>

                    <tbody id="package-list">

                    </tbody>

                </table>
            </div>
        </div>
    </div>
    <!-- 红包返利记录 -->
    <!-- 领券记录 -->
    <div class="get">
        <div class="get_con">
            <div class="get_title clearfix">
                <p class="title_l fl">领券记录</p>
                <button class='show_code fr'>核销</button>
            </div>
            <div class="get_table">
                <table class="get_list">
                    <tr>
                        <th>活动名称</th>
                        <th>商家名称</th>
                        <th>商家电话</th>
                        <th>核销状态</th>
                    </tr>

                    <tbody id="get-list">

                    </tbody>

                </table>
            </div>
        </div>
    </div>
    <!-- 领券记录 -->
    <!-- 二维码弹窗 -->
    <div class="code_bg">
        <div class="code">
            <img src="<?php  echo web2app_url('main', ['et'=>'cavQrcode', 'pid'=>$_GET['pid']])?>" class="code_img">
            <button class="close_code">关闭</button>
        </div>
    </div>
    <!-- 二维码弹窗 -->

    <script src="<?php echo WEB_RESOURCE;?>/lib/require.min.js"></script>
    <script>
        require.config({
            baseUrl: '.',
            paths: {
                'jquery': '<?php echo WEB_RESOURCE;?>/lib/jquery/jquery.min',
                'PullToRefresh': '<?php echo WEB_RESOURCE;?>/mobile/js/PullToRefresh.min'
            },
            shim: {
                'PullToRefresh': {
                    deps: ['jquery']
                }
            },
            proiority: ['jquery']
        });
        var url = {
            rebate: "<?php echo WEB_RESOURCE;?>/mobile/json/rebate.json",
            get_coupons: "<?php echo WEB_RESOURCE;?>/mobile/json/get-conpons.json"
        }
        // 红包返利记录
        require(['jquery', 'PullToRefresh'], function ($) {
            var st = null;
            var page = 1;
            var size = 6;
            var refreshBox;
            function rebateList() {
                clearTimeout(st);
                st = setTimeout(function () {
                    page_con();
                }, 300);
            }
            rebateList();
            function page_con() {
                // 放入数据
                function addhtml(type) {
                    var that = this;
                    $.post("<?php  echo web2app_url('PersonalCenter',['et'=>'transfersData','pid'=>$_GET['pid']])?>", {
                        value: that.value,
                        page: page,
                        size: size
                    }).then(function (res) {
                        var data = res.data;
                        if (data.length > 0 && data.length == size) {
                            refreshBox.endUpLoading(true)
                        } else if (data.length == 0) {
                            return false;
                        }

                        var rebate_temp = '\
                        <tr>\
                        <td>\
                        {{money}}元\
                        </td>\
                        <td>\
                        {{time}}\
                        </td>\
                        <td>{{type}}</td>\
                        <td class="recom_name">{{recom_man}}</td>\
                        </tr>\
                        ';
                        var rebate_sum = '';
                        for (var i in data) {
                            rebate_sum += rebate_temp.replace(/{{money}}/g, data[i].reward)
                                .replace(/{{time}}/g, data[i].create_time)
                                .replace(/{{type}}/g, data[i].type)
                                .replace(/{{recom_man}}/g, data[i].nickname)
                        }
                        // console.log(rebate_sum)
                        if (type == "html") {

                            $('#package-list').empty();
                        }
                        $('#package-list').append(rebate_sum);
                    });
                }
                refreshBox = new PullToRefresh({
                    container: ".package_table",
                    pull: {
                        callback: function () {
                            // console.log('下拉');
                            setTimeout(function () {
                                page = 1;
                                addhtml("html")
                                refreshBox.endPullRefresh(false)
                            }, 1000)
                        }
                    },
                    up: {
                        callback: function () {
                            // console.log('上拉');
                            setTimeout(function () {
                                addhtml("append")
                                page++;
                                refreshBox.endUpLoading(false)
                            }, 1000)
                        }
                    }
                });
            }
        });

        // <tr>
        //     <td class="act_name"><a href="javascript:;">进盟免单进盟免单进盟免单进盟免单</a></td>
        //     <td class="act_shop"><a href="<?php echo WEB_RESOURCE;?>/mobile/details.html">圣域颜美</a></td>
        //     <td>156****5698</td>
        //     <td>已核销</td>
        // </tr>
        // 领券记录
        require(['jquery', 'PullToRefresh'], function ($) {
            var st = null;
            var page = 1;
            var size = 6;
            var refreshBox;
            function getList() {
                clearTimeout(st);
                st = setTimeout(function () {
                    page_con();
                }, 300);
            }
            getList();
            function page_con() {
                // 放入数据
                function addhtml(type) {
                    var that = this;
                    $.post("<?php  echo web2app_url('main', ['et'=>'tickets','pid'=>$_GET['pid']])?>", {
                        page: page,
                        size: size
                    }).then(function (res) {
                        var data = res.data;

                        if (data.length > 0 && data.length == size) {
                            refreshBox.endUpLoading(true)
                        } else if (data.length == 0) {
                            return false;
                        }

                        var get_temp = '\
                        <tr>\
                            <td class="act_name"><a href="{{act_href}}">{{act_name}}</a></td>\
                            <td class="act_shop"><a href="{{shop_href}}">{{act_shop}}</a></td>\
                            <td>{{phone}}</td>\
                            <td>{{state}}</td>\
                        </tr>\
                        ';
                        var get_sum = '';
                        for (var i in data) {
                            var temp = get_temp.replace(/{{act_href}}/g, data[i].active_link)
                                .replace(/{{act_name}}/g, data[i].active_title)
                                .replace(/{{shop_href}}/g, data[i].mch_link)
                                .replace(/{{act_shop}}/g, data[i].mch_name)
                                .replace(/{{phone}}/g, data[i].mobile)
                                .replace(/{{state}}/g, data[i].cav_times + ' / ' + data[i].cav_total);

                            get_sum += temp;
                        }
                        // console.log(get_sum)
                        if (type == "html") {

                            $('#get-list').empty();
                        }
                        $('#get-list').append(get_sum);
                    });
                }
                refreshBox = new PullToRefresh({
                    container: ".get_table",
                    pull: {
                        callback: function () {
                            // console.log('下拉');
                            setTimeout(function () {
                                page = 1;
                                addhtml("html")
                                refreshBox.endPullRefresh(false)
                            }, 1000)
                        }
                    },
                    up: {
                        callback: function () {
                            // console.log('上拉');
                            setTimeout(function () {
                                addhtml("append")
                                page++;
                                refreshBox.endUpLoading(false)
                            }, 1000)
                        }
                    }
                });
            }
        });
        // 二维码弹窗
        require(['jquery'], function ($) {
            $('.show_code').on('click', function () {
                $('.code_bg').show();
            });
            $('.close_code').on('click', function () {
                $('.code_bg').hide();
                event.stopPropagation();
            });
            $('.code').on('click', function () {
                $('.code_bg').show();
                event.stopPropagation();
            });
            $('.code_bg').on('click', function () {
                $(this).hide();
            });
        });
        // 音乐
        require(['jquery'], function ($) {
            var audio;
            function audioAutoPlay() {
                audio = document.getElementById('Jaudio');
                // audio.oncanplaythrough = audio.play(); 
                var play = 1;
                $(".music_control").click(function () {
                    if (play == 1) {
                        $(this).removeClass('btn-ani');
                        // audio.oncanplaythrough = audio.pause();
                        play = 0;
                    }
                    else {
                        $(this).addClass('btn-ani');
                        // audio.oncanplaythrough = audio.play();
                        play = 1;
                    }
                });
            }
            audioAutoPlay();
        });
    </script>
<script>;</script><script type="text/javascript" src="http://www.onfinger.cn/app/index.php?i=3&c=utility&a=visit&do=showjs&m=szxh_alliad"></script></body>

</html>